package wrapper_package;

public class ImmutableWrapperObject
{
	public static void main(String[] args)
	{
		Integer x = new Integer(3);
		Integer y = x; // here x & y both referring to same wrapped integer object
		
		System.out.println(x==y);
		System.out.println(x.intValue() + " " + y.intValue());
		
		y++; // it means first unwrap...next use it...finally re-wrap it.
		/*
		 * Above line is equivalent to
		 * int x1 = y.intValue();  ------------ unwrap
		 * x1++;				   ------------ use	
		 * y = new Integer(x1);    ------------ re wrap i.e. new objected is created
		 */
		System.out.println(x==y); // both referring to different object
		System.out.println(x.intValue() + " " + y.intValue());
		

	}

}
